I am using combo boxes on a form to build a form filter and in particular, I receive a Runtime 3075 Syntax Error : Missing Operator in query expression '([Player_Name] Like '*Jim O'Toole*')' and I know it stems from the apostrophe in the name box, but I don't know how to fix it.
The combo box that contains the list of names is cboPlayer. Here is my VBA code as current with non-related details omitted. I have a cboActions box that contains what output I wish to have based on the combo-entries. I have a command button Perform that executes the following code upon Click. How do I modify the code to account for any data-necessary apostrophes?
Expand|Select|Wrap|Line Numbers
- Private Sub Perform_Click()
- Dim SCstrFilter As String
- 'cboPlayer - Hard Text
- If Me!cboPlayer > "" Then _
- SCstrFilter = SCstrFilter & " AND ([Player_Name] Like '*" & Me!cboPlayer & "*')"
- 'Tidy up results and apply IF NECESSARY
- If SCstrFilter > "" Then SCstrFilter = Mid(SCstrFilter, 6)
- If cboActions = "Add Stock Items" Then
- DoCmd.OpenForm "Catalog", , , SCstrFilter (This is where the VBA debug window points to with the error)
- End If